/****** NSurvey database upgrade v1.1 -> v1.2 ******/
use [NSurvey]
go
create table vts_tbEmailNotificationSettings(
  SurveyId     int           not null constraint PK_vts_tbEmailNotificationSettings primary key,
  EmailFrom    nvarchar(255),
  EmailTo      nvarchar(255),
  EmailSubject nvarchar(255)
)
go

alter table vts_tbEmailNotificationSettings add
  constraint FK_vts_tbEmailNotificationSettings_vts_tbSurvey foreign key(SurveyId) references vts_tbSurvey(SurveyID) on delete cascade
go

create table vts_tbNotificationMode(
  NotificationModeID int          not null constraint PK_vts_tbNotificationMode primary key,
  Description        nvarchar(50)
)
go

create table vts_tbProgressDisplayMode(
  ProgressDisplayModeId int          not null constraint PK_ProgressDisplayMode primary key,
  Description           nvarchar(50)
)
go

alter table vts_tbQuestion drop
  constraint FK_vts_tbQuestion_vts_tbQuestionSelectionMode
go

alter table vts_tbQuestion add
  constraint FK_vts_tbQuestion_vts_tbQuestionSelectionMode foreign key(SelectionModeId) references vts_tbQuestionSelectionMode(QuestionSelectionModeID) on delete cascade
go

alter table vts_tbSurvey add
  ProgressDisplayModeId int constraint DF_vts_tbSurvey_ProgressDisplayModeId default (2),
  NotificationModeID int constraint DF_vts_tbSurvey_NotificationModeID default (1),
  NavigationEnabled bit constraint DF_vts_tbSurvey_NavigationEnabled default (0),
  AllowResume bit constraint DF_vts_tbSurvey_AllowResume default (0)
go

alter table vts_tbSurvey add
  constraint FK_vts_tbSurvey_vts_tbNotificationMode foreign key(NotificationModeID) references vts_tbNotificationMode(NotificationModeID),
  constraint FK_vts_tbSurvey_vts_tbProgressDisplayMode foreign key(ProgressDisplayModeId) references vts_tbProgressDisplayMode(ProgressDisplayModeId)
go

alter table vts_tbVoter add
  ResumeUID nvarchar(40),
  ResumeAtPageNumber int,
  ProgressSaveDate datetime,
  ResumeQuestionNumber int
go

alter PROCEDURE vts_spSurveyClone @SurveyID int 
AS
BEGIN TRANSACTION CloneSurvey
DECLARE @ClonedSurveyId int
-- Clone the survey
INSERT INTO vts_tbSurvey 
	(CreationDate, 
	OpenDate,
	CloseDate,
	Title,
	RedirectionURL,
	ThankYouMessage,
	AccessPassword,
	SurveyDisplayTimes,
	ResultsDisplayTimes,
	Archive,
	Activated,
	IPExpires,
	CookieExpires,
	OnlyInvited,
	NavigationEnabled,
	AllowResume,
	ProgressDisplayModeId,
	NotificationModeId)
SELECT      
	getdate(), 
	OpenDate,
	CloseDate,
	Title + ' - cloned',
	RedirectionURL,
	ThankYouMessage,
	AccessPassword,
	0,
	0,
	Archive,
	0,
	IPExpires,
	CookieExpires,
	OnlyInvited,
	NavigationEnabled,
	AllowResume,
	ProgressDisplayModeId,
	NotificationModeId

FROM vts_tbSurvey WHERE SurveyID = @SurveyID
-- Check if the cloned survey was created
IF @@rowCount <> 0
BEGIN
	-- Clone the survey's questions
	set @ClonedSurveyID = Scope_Identity()
	INSERT INTO vts_tbEmailNotificationSettings(SurveyId, EmailFrom, EmailTo, EmailSubject) 
		SELECT @ClonedSurveyID as surveyid,EmailFrom, Emailto, EmailSubject 
		FROM vts_tbEmailNotificationSettings 
		WHERE SurveyID = @SurveyID
	
	INSERT INTO vts_tbSurveyWebSecurity(WebSecurityAddinId, SurveyID, AddInOrder, Disabled)
		SELECT WebSecurityAddinId, @ClonedSurveyID as SurveyID, AddInOrder, Disabled
		FROM vts_tbSurveyWebSecurity
		WHERE SurveyID = @SurveyID

	exec vts_spQuestionCopyToSurvey @SurveyID, @ClonedSurveyID
END
COMMIT TRANSACTION CloneQuestion
exec vts_spSurveyGetDetails @ClonedSurveyID
go

/*
/// <summary>
/// Get all surveys available in the database
/// </summary>
*/
alter PROCEDURE vts_spSurveyGetAllDetails AS
SELECT 
	vts_tbSurvey.SurveyID,
	UnAuthentifiedUserActionID,
	CreationDate,
	Title,
	AccessPassword,
	RedirectionURL, 
	OpenDate,
	CloseDate,
	LastEntryDate,
	(Select count(*) FROM vts_tbVoter WHERE Validated<>0 AND SurveyID = vts_tbSurvey.SurveyID) as VoterNumber,
	(Select max(PageNumber) FROM vts_tbQuestion WHERE SurveyID = vts_tbSurvey.SurveyID) as TotalPageNumber,
	SurveyDisplayTimes,
	ResultsDisplayTimes,
	Archive,
	Activated,
	IPExpires,
	CookieExpires,
	OnlyInvited,
	NavigationEnabled,
	AllowResume,
	ProgressDisplayModeId,
	NotificationModeId,
	EmailFrom,
	EmailTo,
	EmailSubject

FROM vts_tbSurvey
LEFT JOIN vts_tbEmailNotificationSettings 
	ON vts_tbSurvey.SurveyID = vts_tbEmailNotificationSettings.SurveyID
ORDER BY vts_tbSurvey.SurveyID
go

/*
/// <summary>
/// Get the details of a survey
/// </summary>
/// <param name="@SurveyID">
/// ID of the survey to get details of
/// </param>
*/
alter PROCEDURE vts_spSurveyGetDetails @SurveyID int  AS
SELECT 
	vts_tbSurvey.SurveyID,
	UnAuthentifiedUserActionID,
	CreationDate,
	Title,
	AccessPassword,
	RedirectionURL, 
	OpenDate,
	CloseDate,
	LastEntryDate,
	(Select count(*) FROM vts_tbVoter WHERE Validated<>0 AND SurveyID = @SurveyID) as VoterNumber,
	(Select max(PageNumber) FROM vts_tbQuestion WHERE SurveyID = @SurveyID) as TotalPageNumber,
	SurveyDisplayTimes,
	ResultsDisplayTimes,
	Archive,
	Activated,
	IPExpires,
	CookieExpires,
	ThankYouMessage,
	OnlyInvited,
	NavigationEnabled,
	AllowResume,
	ProgressDisplayModeId,
	NotificationModeId,
	EmailFrom,
	EmailTo,
	EmailSubject
FROM vts_tbSurvey 
LEFT JOIN vts_tbEmailNotificationSettings 
	ON vts_tbSurvey.SurveyID = vts_tbEmailNotificationSettings.SurveyID
WHERE vts_tbSurvey.SurveyID = @SurveyId
go

/*
/// <summary>
///  Updates a survey
/// </summary>
/// <param name="@SurveyID">
/// ID of the survey  to update
/// </param>
/// <param name="@Title">
/// Title of the poll
/// </param>
/// <param name="@Archive">
/// Is the survey archived ?
/// </param>
/// <param name="@Activated">
/// Is the survey activated ?
/// </param>
/// <remarks>
/// Only one survey can be activated at one time
/// </remarks>
*/
alter PROCEDURE vts_spSurveyUpdate 
				@SurveyID int,
				@Title nvarchar(255),
				@RedirectionURL varchar(1024),
				@ThankYouMessage nvarchar(4000),
				@OpenDate datetime,
				@CloseDate datetime,
				@Archive bit,
				@Activated bit,
				@OnlyInvited bit,
				@NavigationEnabled bit,
				@AllowResume bit,
				@ProgressDisplayModeId int,
				@NotificationModeId int
AS
if @Activated <> 0
-- Only one survey can be activated at one time
	UPDATE vts_tbSurvey SET Activated = 0 WHERE Activated<>0
UPDATE vts_tbSurvey 
SET 
	Title = @Title, 
	RedirectionURL = @RedirectionURL,
	OpenDate = @OpenDate,
	CloseDate = @CloseDate,
	Archive = @Archive, 
	Activated = @Activated,
	ThankYouMessage = @ThankYouMessage,
	OnlyInvited = @OnlyInvited,
	NavigationEnabled = @NavigationEnabled,
	AllowResume = @AllowResume,
	ProgressDisplayModeId = @ProgressDisplayModeId,
	NotificationModeId = @NotificationModeId

WHERE SurveyID = @SurveyID
go

/*
/// <summary>
/// Adds a new voter
/// </summary>
/// <param name="@SurveyID">
/// To which survey belongs this voters (Denormalized to gain performance on select queries)
/// </param>
/// <param name="@IPSource">
/// Source of the IP
/// </param>
/// <param name="@VoteDate">
/// Date of the vote
/// </param>
/// <param name="@Validated">
/// Has the voter already been validated ? (OPTIONAL AT THIS TIME)
/// </param>
/// <param name="@VoterID">
/// Created voter's ID
/// </param>
*/
alter PROCEDURE vts_spVoterAddNew
			@SurveyID int,
			@IPSource nvarchar(50),
			@VoteDate datetime,
			@StartDate datetime,
			@UID varchar(50),
			@Validated bit = 1, 
			@ResumeUID varchar(50),
			@ProgressSaveDate datetime,
			@ResumeAtPageNumber int,
			@ResumeQuestionNumber int,
			@VoterID int OUTPUT
AS
INSERT INTO vts_tbVoter
	(SurveyID,
	UID,
	IPSource , 
	VoteDate,
	StartDate,
	Validated,
	ResumeUID,
	ProgressSaveDate,
	ResumeAtPageNumber,
	ResumeQuestionNumber)
VALUES
	 (@SurveyID,
	@UID,
	@IPSource,
	@VoteDate,
	@StartDate,
	@Validated,
	@ResumeUID,
	@ProgressSaveDate,
	@ResumeAtPageNumber,
	@ResumeQuestionNumber)

set @VoterID = SCOPE_Identity()
if @UID is not null
BEGIN 
	exec vts_spVoterUIdAddNew @VoterID, @UId
END
Update vts_tbSurvey set LastEntryDate = GetDate() WHERE SurveyID = @SurveyID
go

alter PROCEDURE vts_spVoterGetAnswers @VoterID int
AS
	SELECT 
		vts_tbVoter.VoterID,
		SurveyID,
		VoteDate,
		IPSource,
		Validated,
		StartDate,
		Email,
		ResumeUID,
		ProgressSaveDate,
		ResumeAtPageNumber,
		ResumeQuestionNumber
	FROM vts_tbVoter
	LEFT JOIN vts_tbVoterEmail 
		ON vts_tbVoter.VoterID = vts_tbVoterEmail.VoterID
	LEFT JOIN vts_tbEmail
		ON vts_tbEmail.EmailID = vts_tbVoterEmail.EmailId
	WHERE vts_tbVoter.VoterID = @VoterID
	
	SELECT va.VoterID, va.AnswerID, va.AnswerText, a.QuestionID
	FROM vts_tbVoterAnswers va	
	INNER JOIN vts_tbAnswer a
		ON a.AnswerID = va.AnswerID
	WHERE VoterID = @VoterID
go

/*
/// <summary>
/// Get all surveys email notification modes
/// </summary>
*/
create PROCEDURE vts_spNotificationModeGetAll AS
SELECT * FROM vts_tbNotificationMode
go

/*
/// <summary>
/// Get all surveys progress modes
/// </summary>
*/
create PROCEDURE vts_spProgressModeGetAll AS
SELECT * FROM vts_tbProgressDisplayMode
go

create PROCEDURE vts_spEmailNotificationSettingsAddNew
					@SurveyID int,
					@EmailFrom varchar(255),
					@EmailTo varchar(255),
					@EmailSubject varchar(255)
 AS

UPDATE vts_tbEmailNotificationSettings SET EmailFrom=@EmailFrom, EmailTo=@EmailTo, EmailSubject = @EmailSubject WHERE SurveyID = @SurveyID

if @@rowcount = 0
BEGIN
	INSERT INTO vts_tbEmailNotificationSettings (SurveyID, EmailFrom, EmailTo, EmailSubject) 
	VALUES (@SurveyID, @EmailFRom, @EmailTo, @EmailSubject)
END
go

create PROCEDURE vts_spEmailNotificationSettingsDelete
					@SurveyID int
 AS


DELETE FROM vts_tbEmailNotificationSettings WHERE SurveyID = @SurveyID
go

/*
/// <summary>
/// Copy an existing question to another survey
/// </summary>
*/
create PROCEDURE vts_spQuestionCopy
				@QuestionID int, 
				@NewSurveyID int,
				@DisplayOrder int,
				@PageNumber int,
				@QuestionCopyID int output
AS

BEGIN TRANSACTION CopyQuestion

INSERT INTO vts_tbQuestion  
	(ParentQuestionId, 
	SurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	DisplayOrder,
	PageNumber, 
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText)
SELECT      
	ParentQuestionId, 
	@NewSurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	@DisplayOrder,
	@PageNumber, 
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText
FROM vts_tbQuestion WHERE QuestionID = @QuestionID

-- Check if the cloned question was created
IF @@rowCount <> 0
BEGIN
	-- Clone the question's answers
	set @QuestionCopyID = Scope_Identity()
	exec vts_spQuestionChildsClone @QuestionID, @QuestionCopyID, @NewSurveyID
	UPDATE vts_tbQuestion SET DisplayOrder = @DisplayOrder, PageNumber = @PageNumber 
	WHERE SurveyID = @NewSurveyID AND ParentQuestionid = @QuestionCopyID

	exec vts_spAnswersCloneByQuestionId @QuestionID, @QuestionCopyID

	-- Update the display order
	UPDATE vts_tbQuestion 
	SET DisplayOrder = DisplayOrder + 1 
	WHERE 
		SurveyID = @NewSurveyID AND
		((QuestionID<>@QuestionCopyID AND ParentQuestionID is null) OR
 		(ParentQuestionID is not null AND ParentQuestionID <> @QuestionCopyID)) AND
 		DisplayOrder >= @DisplayOrder
END

COMMIT TRANSACTION CopyQuestion
go

/*
/// <summary>
/// Get a list of al parentl question that can have any type of answers
/// </summary>
/// <param name="@SurveyID">
/// ID of the survey  to retrieve questions
/// </param>
/// <returns>
///	QuestionID,
///	SurveyID
///	QuestionText, 
/// </returns>
*/
create PROCEDURE vts_spQuestionAnswerableListWithoutChilds @SurveyId int  AS
SELECT DISTINCT Q.QuestionID, Q.QuestionText, Q.DisplayOrder 
FROM vts_tbQuestion Q
INNER JOIN vts_tbQuestionSelectionMode
	ON  QuestionSelectionModeID= Q.SelectionModeID
WHERE 
	SurveyID = @SurveyId AND 
	TypeMode & 4 > 1 AND 
	ParentQuestionID is null
ORDER BY Q.DisplayOrder, Q.QuestionID
go

/*
/// <summary>
///  returns the number of unvalidated entries that 
/// have been saved
/// </summary>
*/
create PROCEDURE vts_spVoterGetUnvalidatedCount
				@SurveyID int
AS

SELECT count(voterid) as UnvalidatedCount FROM vts_tbVoter
WHERE SurveyID = @SurveyID AND Validated = 0
go

/*
/// <summary>
/// Deletes all saved progress entries that have not 
/// been validated
/// </summary>
*/
create PROCEDURE vts_spVoterDeleteUnvalidated
				@SurveyID int
AS

DELETE FROM vts_tbVoter WHERE SurveyID = @SurveyID AND Validated = 0
go

/*
/// <summary>
/// Check if the given page of the survey has branching rules associated with it
/// </summary>
*/
create PROCEDURE vts_spSurveyHasPageBranching @SurveyID int, @PageNumber int 
AS

SELECT top 1 vts_tbBranchingRule.BranchingRuleID FROM vts_tbBranchingRule 
INNER JOIN vts_tbQuestion
	ON vts_tbQuestion.QuestionID = vts_tbBranchingRule.QuestionID
WHERE vts_tbQuestion.SurveyID = @SurveyID AND vts_tbBranchingRule.PageNumber = @PageNumber
go

/*
/// <summary>
/// Get a list of all questions in the given page range for a survey
/// </summary>
/// <param name="@SurveyID">
/// ID of the survey  to retrieve questions
/// </param>
/// <returns>
///	QuestionID,
///	QuestionText, 
/// </returns>
*/
create PROCEDURE vts_spQuestionsGetPageRangeForSurvey 
			@SurveyId int,
			@StartPage int,
			@EndPage int
AS

SELECT 
	QuestionID,
	QuestionText 
FROM vts_tbQuestion
WHERE 
	SurveyID=@SurveyId AND PageNumber BETWEEN @StartPage AND @EndPage
go

alter PROCEDURE vts_spNSurveyGetVersion  AS
SELECT '1.2' as version
go

/*
/// <summary>
/// Clones a child question and its answers
/// </summary>
/// <param name="@QuestionID">
/// ID of the child question to clone
/// </param>
/// <param name="@ParentQuestionID">
/// Parent of the child question
/// </param>
/// <return>
/// returns the cloned question
/// </return>
*/
alter PROCEDURE vts_spQuestionChildCloneById 
				@QuestionID int, 
				@ParentQuestionID int,
				@SurveyID int
AS
INSERT INTO vts_tbQuestion  
	(ParentQuestionId, 
	SurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	DisplayOrder,
	PageNumber, 
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText)
SELECT      
	@ParentQuestionID, 
	@SurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	DisplayOrder,
	PageNumber,
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText 
FROM vts_tbQuestion WHERE QuestionID = @QuestionID
-- Check if the cloned question was created
IF @@rowCount <> 0
BEGIN
	DECLARE @ClonedQuestionID int
	-- Clone the question's answers
	set @ClonedQuestionID = Scope_Identity()
	exec vts_spAnswersCloneByQuestionId @QuestionID, @ClonedQuestionID
END
go

/*
/// <summary>
/// Clones a question and its answers
/// </summary>
/// <param name="@QuestionID">
/// ID of the question to clone
/// </param>
/// <return>
/// returns the cloned question
/// </return>
*/
alter PROCEDURE vts_spQuestionCloneByID @QuestionID int AS
BEGIN TRANSACTION CloneQuestion
DECLARE 
	@ClonedQuestionId int,
	@OldDisplayOrder int,
	@SurveyID int
-- Clone the question
INSERT INTO vts_tbQuestion  
	(ParentQuestionId, 
	SurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	DisplayOrder,
	PageNumber, 
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText)
SELECT      
	ParentQuestionId, 
	SurveyID, 
	SelectionModeId, 
	LayoutModeId, 
	DisplayOrder,
	PageNumber, 
	MinSelectionRequired, 
	MaxSelectionAllowed, 
	RatingEnabled,
	ColumnsNumber,
	RandomizeAnswers,
	QuestionText + ' - Cloned'
FROM vts_tbQuestion WHERE QuestionID = @QuestionID
-- Check if the cloned question was created
IF @@rowCount <> 0
BEGIN
	-- Clone the question's answers
	set @ClonedQuestionID = Scope_Identity()
	SELECT @OldDisplayOrder = DisplayOrder, @SurveyID = SurveyID 
	FROM vts_tbQuestion WHERE QuestionID = @QuestionID
	exec vts_spAnswersCloneByQuestionId @QuestionID, @ClonedQuestionID
	-- Clone question's child question, if any available
	exec vts_spQuestionChildsClone @QuestionID, @ClonedQuestionID, @SurveyID
	-- Update the display order
	UPDATE vts_tbQuestion 
	SET DisplayOrder = DisplayOrder + 1 
	WHERE 
		SurveyID = @SurveyID AND
		((QuestionID<>@ClonedQuestionID AND ParentQuestionID is null) OR
 		(ParentQuestionID is not null AND ParentQuestionID <> @ClonedQuestionID)) AND
 		DisplayOrder >= @OldDisplayOrder 
END
COMMIT TRANSACTION CloneQuestion
exec vts_spQuestionGetDetails @ClonedQuestionID
go

/*
/// <summary>
/// Copy all question of a survey to another survey, mainly used in the clone survey process
/// </summary>
*/
alter PROCEDURE vts_spQuestionCopyToSurvey 
				@SurveyID int, 
				@NewSurveyID int
AS
DECLARE @QuestionID int
DECLARE @QuestionCopyID int
DECLARE QuestionListCursor  CURSOR FOR
	SELECT QuestionID FROM vts_tbQuestion
	WHERE SurveyID = @SurveyID AND ParentQuestionid is null
OPEN QuestionListCursor
FETCH QuestionListCursor INTO @QuestionID
WHILE @@FETCH_STATUS = 0
BEGIN
	INSERT INTO vts_tbQuestion  
		(ParentQuestionId, 
		SurveyID, 
		SelectionModeId, 
		LayoutModeId, 
		DisplayOrder,
		PageNumber, 
		MinSelectionRequired, 
		MaxSelectionAllowed, 
		RatingEnabled,
		ColumnsNumber,
		RandomizeAnswers,
		QuestionText)
	SELECT      
		ParentQuestionId, 
		@NewSurveyID, 
		SelectionModeId, 
		LayoutModeId, 
		DisplayOrder,
		PageNumber, 
		MinSelectionRequired, 
		MaxSelectionAllowed, 
		RatingEnabled,
		ColumnsNumber,
		RandomizeAnswers,
		QuestionText
	FROM vts_tbQuestion WHERE QuestionID = @QuestionID
-- Check if the cloned question was created
IF @@rowCount <> 0
BEGIN
	-- Clone the question's answers
	set @QuestionCopyID = Scope_Identity()
	exec vts_spQuestionChildsClone @QuestionID, @QuestionCopyID, @NewSurveyID
	exec vts_spAnswersCloneByQuestionId @QuestionID, @QuestionCopyID
END
FETCH QuestionListCursor INTO @QuestionID
END
go

/*
/// <summary>
/// Deletes a resume session of a voter from the DB
/// </summary>
*/
create PROCEDURE vts_spVoterDeleteResumeSession @SurveyId int, @ResumeUID nvarchar(40) 
AS

DECLARE @VoterID int

DELETE FROM vts_tbVoterEmail WHERE VoterID IN (SELECT VoterID FROM vts_tbVoter WHERE SurveyID = @SurveyID AND ResumeUID = @ResumeUID)
DELETE FROM vts_tbVoter WHERE SurveyID = @SurveyID AND ResumeUID = @ResumeUID
go

/*
/// <summary>
/// Returns the voter info and his answers for the 
/// session to resume
/// </summary>
*/
create PROCEDURE vts_spVoterResumeSession 
			@SurveyID int, 
			@ResumeUId nvarchar(40)
AS

DECLARE @VoterID int

	SELECT @VoterID = VoterID
	FROM vts_tbVoter
	WHERE SurveyID  = @SurveyID AND ResumeUid = @ResumeUid AND Validated = 0

	if @@rowcount > 0
	BEGIN
		exec vts_spVoterGetAnswers @VoterID
	END
go
Insert into [vts_tbProgressDisplayMode] ([ProgressDisplayModeId], [Description]) values(1, 'NoProgressText')
Insert into [vts_tbProgressDisplayMode] ([ProgressDisplayModeId], [Description]) values(2, 'PageNumberText')
Insert into [vts_tbProgressDisplayMode] ([ProgressDisplayModeId], [Description]) values(3, 'ProgressPercentageText')
GO
Insert into [vts_tbNotificationMode] ([NotificationModeID], [Description]) values(1, 'NoneNotificationText')
Insert into [vts_tbNotificationMode] ([NotificationModeID], [Description]) values(2, 'ShortNotificationText')
Insert into [vts_tbNotificationMode] ([NotificationModeID], [Description]) values(3, 'ReportNotificationText')
GO
Insert into [vts_tbAnswerType] ([BuiltIn], [Description], [FieldWidth], [FieldHeight], [FieldLength], [TypeMode], [XMLDataSource], [PublicFieldResults], [JavascriptFunctionName], [JavascriptCode], [JavascriptErrorMessage], [TypeNameSpace], [TypeAssembly]) values(1, 'FieldHiddenType', 0, 0, 0, 2, NULL, 0, NULL, NULL, NULL, 'Votations.NSurvey.WebControls.UI.AnswerFieldHiddenItem', 'Votations.NSurvey.WebControls')
GO
UPDATE vts_tbSurvey SET NavigationEnabled = 0, AllowResume = 0, NotificationModeID = 1, ProgressDisplayModeId = 2
go